package com.ecoolex.chinadutyfree.retailer.core.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecoolex.chinadutyfree.retailer.core.dao.DirectMailGoodsOrderNoDAO;
import com.ecoolex.chinadutyfree.retailer.entity.DirectMailGoodsOrderNo;

import java.sql.Date;
import java.time.Instant;

@Service
public class DirectMailGoodsOrderNoManager {

    @Autowired
    private DirectMailGoodsOrderNoDAO dao;

    public String builder(String createUser) {
        DirectMailGoodsOrderNo record = new DirectMailGoodsOrderNo();
        record.setDeleted(DirectMailGoodsOrderNo.NOT_DELETED);
        record.setCreateUser(createUser);
        record.setCreateTime(Date.from(Instant.now()));
        record.setUpdateUser(createUser);
        record.setUpdateTime(Date.from(Instant.now()));
        dao.insertAutoKey(record);
        return record.getOrderNo().toString();
    }
}